﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace TB_WS.Class
{
    public class HB_Log
    {
        public static DataSet get_HongBao_Where(int Seller_ID,string Where_Str)
        {
            string sql = "select id,Seller_ID,QR_scene_id,QR_ticket,Tids,dbo.from_unixtime(Create_Time)[Create_Time],(HongBao_List.Money/100)[Money],Create_From,case Type when 'Collected' then '已领取' when 'Wait_Collect' then '等待领取-好评返现' when 'Wait_Collect_Rate_2' then '等待领取-回评返现' when 'UN_Collect' then '好评返现-无条件' when 'End' then '作废红包' else '其他' end[Type],Contet from HongBao_List where Seller_ID=" + Seller_ID+" and "+Where_Str;
            return Class.Unit.db_Conn.select(sql);
        }

        public static DataSet get_Get_HB_Where(int Seller_ID, string Where_Str)
        {
            string sql = "select OpenID,WX_Nick,mch_billno,Get_Time,QR_ticket,Tids,dbo.from_unixtime(Create_Time)[Create_Time],(HongBao_List.Money/100)[Money],Create_From,Type,Contet from HB_Get_Log,HongBao_List where HB_Get_Log.QR_scene_ID=HongBao_List.QR_scene_id and HB_Get_Log.Seller_ID=" + Seller_ID + " and " + Where_Str;
            return Class.Unit.db_Conn.select(sql);
        }

        public static int insert_Get_HB_Log(int Seller_ID,string QR_scene_id,string OpenID,string WX_Nick,string mch_billno,string Get_Time,string HB_JSON)
        {
            string sql = "insert into HB_Get_Log values(" + Seller_ID +
                ",'" + QR_scene_id + "','" + OpenID + "','" + WX_Nick +
                "','" + mch_billno + "','" + Get_Time + "','" + HB_JSON + "')";
            return Class.Unit.db_Conn.Nonquery(sql);
        }

        public static DataSet Get_HB_Log_QR_Scene_id(string QR_Scene_id)
        {
            string sql = "select * from HB_Get_Log where QR_scene_ID='" + QR_Scene_id + "'";
            return Class.Unit.db_Conn.select(sql);
        }


    }
}
